package com.acoffee.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author acoffee
 * @create 2021-11-24 15:35
 */
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(value = Exception.class)
    public ModelAndView handlerError(Exception ex){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("ex",ex);
        modelAndView.setViewName("error");
        return modelAndView;
    }
}
